<?php

use wicked\core\Event;
use wicked\core\Response;
use wicked\core\Session;

/**
 * 404 Not Found
 */
Event::listen('404', function(){
    Response::view('_error/404');
});

/**
 * 403 Forbidden
 */
Event::listen('403', function(){
    Response::view('_error/403');
});

/**
 * Log all event
 */
Event::listen('event.fire', function($event, $args){
    $arg = isset($args[0]) ? ' : ' . implode(', ', $args) : '';
    trace('Event (' . $event . ')' . $arg);
});

/**
 * Benchmark
 */
Event::listen('app.start', function(){
    Session::data('benchmark', microtime(true));
});
Event::listen('app.end', function(){
    $start = Session::data('benchmark');
    $total = number_format(microtime(true) - $start, 4);
    trace('Benchmark : ' . $total . ' sec');
});